package com.geovis.emergency.spd.entity.system.pojo.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.geovis.emergency.spd.entity.basic.pojo.vo.ShareDocTreeVO;
import com.geovis.emergency.spd.entity.system.entity.SystemDept;
import com.geovis.emergency.spd.entity.system.pojo.node.INode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Lonsho
 * @version 1.0
 * @date 2022/9/1
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SystemDeptTreeVO extends SystemDept implements INode<SystemDeptTreeVO> {


    @ApiModelProperty(value = "子集列表")
//    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<SystemDeptTreeVO> children;

    /**
     * 是否有子孙节点
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Boolean hasChildren;


    @Override
    public List<SystemDeptTreeVO> getChildren() {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        return children;
    }

    public static SystemDeptTreeVO fromDept(SystemDept dept)
    {
        SystemDeptTreeVO deptVo=new SystemDeptTreeVO();
        BeanUtils.copyProperties(dept,deptVo);
        return deptVo;
    }
}
